﻿///////////////////////////////////////////////////////////////////////////////////////////////
// System.Text.Parsing - © 2011 Sebastien Pellizzari
// Released under the MIT License (http://www.opensource.org/licenses/mit-license.php)
///////////////////////////////////////////////////////////////////////////////////////////////

namespace System.Text.Parsing
{
    /// <summary>Represents a generic representation of a tokenizer grammar.</summary>
    public sealed class GrammarTokenizer
    {
        private readonly GrammarTextValue _name;                    // The name of the tokenizer.
        private readonly GrammarTextValue _implementation;          // The name of the tokenizer implementation to use.
        private readonly GrammarTokenCollection _tokens;            // The token collection.
        private readonly GrammarPropertyCollection _properties;     // The tokenizer properties.
        private readonly GrammarCodeBlockCollection _codeBlocks;    // The tokenizer code blocks.
        private readonly GrammarTokenGroupCollection _tokenGroups;  // The token group collection.

        //-----------------------------------------------------------------------
        //     Properties
        //-----------------------------------------------------------------------

        /// <summary>Gets the name of the tokenizer.</summary>
        public GrammarTextValue Name { get { return _name; } }
        /// <summary>Gets the name of the tokenizer implementation to use.</summary>
        public GrammarTextValue Implementation { get { return _implementation; } }
        /// <summary>Gets the collection of tokens.</summary>
        public GrammarTokenCollection Tokens { get { return _tokens; } }
        /// <summary>Gets the collection of tokenizer properties.</summary>
        public GrammarPropertyCollection Properties { get { return _properties; } }
        /// <summary>Gets the collection of tokenizer code blocks.</summary>
        public GrammarCodeBlockCollection CodeBlocks { get { return _codeBlocks; } }
        /// <summary>Gets the collection of token groups.</summary>
        public GrammarTokenGroupCollection TokenGroups { get { return _tokenGroups; } }

        //-----------------------------------------------------------------------
        //     Constructors
        //-----------------------------------------------------------------------

        /// <summary>Initializes an instance of the <see cref="GrammarTokenizer"/> class.</summary>
        /// <param name="name">The class name for the tokenizer.</param>
        /// <param name="implementation">A string determining the tokenizer implementation to use.</param>
        public GrammarTokenizer(GrammarTextValue name, GrammarTextValue implementation)
        {
            if (name.Text == null) throw new ArgumentNullException("name.Text");
            if (implementation.Text == null) throw new ArgumentNullException("implementation.Text");
            _name = name;
            _implementation = implementation;
            _tokens = new GrammarTokenCollection();
            _properties = new GrammarPropertyCollection();
            _codeBlocks = new GrammarCodeBlockCollection();
            _tokenGroups = new GrammarTokenGroupCollection();
        }
    }
}
